<?php
/*
 * @Author: 李志刚
 * @CopyRight: 2020-2030 衡水山木枝技术服务有限公司
 * @Date: 2021-10-19 10:21:56
 * @Description: 订单商品表，要记录下每件商品优惠完的单价，退款按优惠完的退，优惠券不给退
 * @LastEditors: 李志刚
 * @LastEditTime: 2021-10-19 18:04:43
 * @FilePath: /归档/base/2021_10_19_102156_create_order_good.php
 */

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateOrderGood extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('order_goods', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->id();
            $table->foreignId('user_id')->default(0)->comment('用户ID');
            $table->foreignId('order_id')->default(0)->comment('订单id');
            $table->foreignId('good_id')->default(0)->comment('商品id');
            $table->string('good_title', 255)->nullable()->comment('商品名称');
            $table->string('good_thumb', 255)->nullable()->comment('商品封面图');
            $table->integer('good_spec_id')->default(0)->comment('商品规格ID');
            $table->string('good_spec_title', 255)->nullable()->comment('商品规格名称');
            $table->unsignedInteger('nums')->default(0)->comment('数量');
            $table->unsignedDecimal('price')->default(0)->comment('单价');
            $table->unsignedDecimal('integral_price')->default(0)->comment('积分优惠金额');
            $table->unsignedDecimal('coupon_price')->default(0)->comment('券优惠金额');
            $table->unsignedDecimal('real_price')->default(0)->comment('优惠后单价');
            $table->unsignedDecimal('total_price')->default(0)->comment('优惠前支付总金额');
            $table->unsignedDecimal('pay_price')->default(0)->comment('最终支付金额');
            $table->tinyInteger('prom_type')->default(0)->comment('0普通商品，1限时，2团购，3满赠，4活动');
            $table->integer('prom_id')->default(0)->comment('活动ID');
            $table->tinyInteger('comment_status')->default(0)->comment('评价状态 1已评价  0待评价');
            $table->tinyInteger('ship_status')->default(0)->comment('发货状态 0未发货 1已发货');
            $table->tinyInteger('status')->default(1)->comment('状态（1正常 0退款 -1退款完成）');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('order_goods');
    }
}
